<template>
  <a-layout-header class="layout-header">
    <div class="layout-header-title"></div>
    <div class="layout-header-nav">
      <div class="layout-header-nav-left">
        <template v-for="(item, index) in nav">
          <div
            class="nav-item"
            :class="{ active: active === index + 1 }"
            :key="index"
            v-if="index < nav.length / 2"
            @click="goPage(item.path, index + 1)"
          >
            {{ item.name }}
          </div>
        </template>
      </div>
      <div class="layout-header-nav-right">
        <template v-for="(item, index) in nav">
          <div
            class="nav-item"
            :class="{ active: active === index + 1 }"
            :key="index"
            v-if="index >= nav.length / 2"
            @click="goPage(item.path, index + 1)"
          >
            {{ item.name }}
          </div>
        </template>
      </div>
    </div>
  </a-layout-header>
</template>

<script>
export default {
  name: "layout-header",
  data() {
    return {
      nav: [
        {
          name: "古迹全览",
          path: "",
        },
        {
          name: "安全监管",
        },
        {
          name: "保护落实",
        },
        {
          name: "活化开发",
        },
        {
          name: "公众反响",
        },
        {
          name: "信息管理",
          path: "",
        },
      ],
      active: 0,
    };
  },
  methods: {
    goPage(path, index) {
      if (!path) return;
      this.active = index;
      this.$router.push({
        path,
      });
    },
  },
  created() {},
};
</script>

<style scoped lang="less">
.layout-header {
  height: auto;
  padding: 0;
  background-color: transparent;
  .layout-header-title {
    height: 80px;
    background: url("~@/assets/img/layout/layout-header-bg.png") no-repeat top /
      100%;
  }
  .layout-header-nav {
    display: flex;
    margin-top: -24px;
    .layout-header-nav-home {
      width: 80px;
      background: url("~@/assets/img/layout/layout-header-menu-home-bg.png")
        no-repeat center / 100%;
      cursor: pointer;
    }
    .layout-header-nav-left,
    .layout-header-nav-right {
      display: flex;
      width: 50%;
      .nav-item {
        width: 180px;
        text-align: center;
        font-size: 20px;
        color: #8ad8ff;
        cursor: pointer;
        user-select: none;

        &:hover {
          color: #bee8ff;
        }

        &.active {
          color: #ffffff;
        }
      }
    }
    .layout-header-nav-left {
      .nav-item {
        padding-right: 30px;
        background: url("~@/assets/img/layout/layout-header-menu-left-bg.png")
          no-repeat center / 100%;
      }
    }
    .layout-header-nav-right {
      justify-content: right;
      .nav-item {
        padding-left: 30px;
        background: url("~@/assets/img/layout/layout-header-menu-right-bg.png")
          no-repeat center / 100%;
      }
    }
  }
}
</style>
